package com.origin.app.utils.dialog

import android.content.Context
import android.graphics.Color
import android.view.animation.Animation
import android.view.animation.LinearInterpolator
import android.view.animation.RotateAnimation
import com.origin.app.R
import com.origin.app.databinding.DialogLoadingBinding
import com.origin.uilibrary.dailog.bese.BaseVBDialog

class LoadingDialog(context: Context) : BaseVBDialog<DialogLoadingBinding>(context) {
    override fun setUpLayoutId(): Int {
        return R.layout.dialog_loading
    }

    override fun doAction() {
        super.doAction()
        setSizeH(BaseVBDialog.getScreenHeightDp(mContext))
        val rotate = RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f)
        val lin = LinearInterpolator()
        rotate.interpolator = lin
        rotate.duration = 1000//设置动画持续时间
        rotate.repeatCount = -1//设置重复次数
        rotate.fillAfter = true//动画执行完后是否停留在执行完的状态
        dialogViewBinding.imgLoading.animation = rotate
    }

    fun setMsg(msg: String) {
        dialogViewBinding.tvMsg.text = msg
    }
}